<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<base href="<%=basePath%>">

<html>
    <head>
        <meta charset="utf-8">
        <title>
            阳光成单系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="System/css/x-admin.css" media="all">

        <link rel="stylesheet" href="System/css/jqpagination.css" />
    </head>

    <style>
        #begin,#upper,#lower,#end{
            width: 40px;
            height: 30px;
            font-size: 20px;
        }
        #a{
            width: 200px;
            height: 30px;
            font-size: 18px;
        }
    </style>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>入库管理</cite></a>
              <a><cite>入库信息管理</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
            <form class="layui-form x-center" method="post" action="putinlocation/selNameLike?page=1" style="width:800px">
                <div class="layui-form-pane" style="margin-top: 15px;">
                  <div class="layui-form-item">
                    <label class="layui-form-label">查询入库信息</label>
<%--                    <div class="layui-input-inline">--%>
<%--                      <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">--%>
<%--                    </div>--%>
<%--                    <div class="layui-input-inline">--%>
<%--                      <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">--%>
<%--                    </div>--%>
                    <div class="layui-input-inline">
                      <input type="text" name="name"  placeholder="请输入货物名称" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:80px">
                        <button class="layui-btn"  type="submit" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                    </div>
                  </div>
                </div> 
            </form>
            <xblock><button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量审核</button><span class="x-right" style="line-height:40px">共有数据：${count} 条</span></xblock>
<%--            <button class="layui-btn" onclick="member_add('添加用户','member-add.jsp','600','500')"><i class="layui-icon">&#xe608;</i>添加</button>--%>
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>
                            <input type="checkbox" name="" value="">
                        </th>
                        <th>
                            入库编号
                        </th>
                        <th>
                            货物名称
                        </th>
                        <th>

                            负责人
                        </th>
                        <th>
                            货物状态
                        </th>
                        <th>
                            审核状态
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody id="tbody">
                <c:forEach items="${allPutIn}" var="a">
                    <tr>
                        <td>
                            <input type="checkbox" value="${a.putinlocationId}" name="">
                        </td>
                        <td>
                            ${a.putinlocationNumber}
                        </td>
                        <td>
                                ${a.ordergoods.ordergoodsName}

                        </td>
                        <td>
                                ${a.employees.employeesName}
                        </td>
                        <td class="td-status">
                            <span class="layui-btn layui-btn-normal layui-btn-mini">
                               ${a.ordergoods.ordergoodsState==0?"未入库":"已入库"}
                            </span>
                        </td>
                        <td class="td-status">
                            <span class="layui-btn layui-btn-normal layui-btn-mini">
                                 <c:if test="${a.putinlocationState==0}">
                                     未审核
                                 </c:if>
                                  <c:if test="${a.putinlocationState==1}">
                                      已审核
                                  </c:if>
                                <c:if test="${a.putinlocationState==2}">
                                    订单异常请重新审核
                                </c:if>
                                <input type="hidden" value="${a.putinlocationTime}">
                            </span>
                        </td>
                        <td>
                            <button type="button" style="background-color: orange; width: 100px;height: 30px; color: white; border: 0px; cursor: pointer " onclick="upwarecode(${a.putinlocationId})">
                                <i class="layui-icon">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;审核&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i>
                            </button>
                            <button type="button" style="background-color: red; width: 100px;height: 30px; color: white; border: 0px; cursor: pointer " onclick="uputcode(${a.putinlocationId})">
                                <i class="layui-icon">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;驳回&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i>
                            </button>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <%--    分页--%>
            <div id="wrapper" style="margin-left:480px">
                <div class="pagination">
                    <a href="javascript:;" onclick="begin1()"  id="begin" class="first" data-action="first">&laquo;</a>
                    <a href="javascript:;" onclick="upper1()"  id="upper" class="previous" data-action="previous">&lsaquo;</a>
                    <input type="text" id="a"  readonly="readonly" value="${pageText}"/>
                    <input type="hidden" id="a1" readonly="readonly" value="${thisPutInPage}">
                    <a href="javascript:;"  onclick="lower1()" id="lower" class="next" data-action="next">&rsaquo;</a>
                    <a href="javascript:;" onclick="end1()"  id="end" class="last" data-action="last">&raquo;</a>
                </div>
                <div class="clearfix"></div> <!-- should probably have a shower after that -->
                <div style="text-align:center;clear:both;margin-top:50px">
                    <%--    <script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>--%>
                    <%--    <script src="/follow.js" type="text/javascript"></script>--%>
                </div>
            </div>
        </div>
        <script src="System/lib/layui/layui.js" charset="utf-8"></script>
        <script src="System/js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use(['laydate','element','laypage','layer'], function(){
                $ = layui.jquery;//jquery
              laydate = layui.laydate;//日期插件
              lement = layui.element();//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层

              //以上模块根据需要引入

              // laypage({
              //   cont: 'page'
              //   ,pages: 100
              //   ,first: 1
              //   ,last: 100
              //   ,prev: '<em><</em>'
              //   ,next: '<em>></em>'
              }); 

            //批量删除提交
             function delAll () {
                 var checks = $('#tbody').find('input[type=checkbox]:checked');
                 var str="";
                 for (var i = 0; i < checks.length; i++) {
                     str+=checks[i].value+",";
                 }
                 layer.confirm('确定通过选择的商品入库吗?',function(index){
                     //捉到所有被选中的，发异步进行删除  提示
                     // layer.msg('操作成功!', {icon: 1});
                     //ajax请求   软删除选中文章数据
                     $.post("putinlocation/upAllPutInCode", {str:str}, function () {
                         alert("选择的商品已成功入库！请查看货物信息！");
                         window.location.reload();
                     });
                 });
             }
             /*用户-添加*/
            function member_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }
            /*用户-查看*/
            function member_show(title,url,id,w,h){
                x_admin_show(title,url,w,h);
            }

             /*用户-停用*/
            function member_stop(obj,id){
                layer.confirm('确认要停用吗？',function(index){
                    //发异步把用户状态进行更改
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="layui-icon">&#xe62f;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="layui-btn layui-btn-disabled layui-btn-mini">已停用</span>');
                    $(obj).remove();
                    layer.msg('已停用!',{icon: 5,time:1000});
                });
            }

            /*用户-启用*/
            function member_start(obj,id){
                layer.confirm('确认要启用吗？',function(index){
                    //发异步把用户状态进行更改
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="layui-icon">&#xe601;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span>');
                    $(obj).remove();
                    layer.msg('已启用!',{icon: 6,time:1000});
                });
            }
            // 用户-编辑
            function member_edit (title,url,id,w,h) {
                x_admin_show(title,url,w,h); 
            }
            /*密码-修改*/
            function member_password(title,url,id,w,h){
                x_admin_show(title,url,w,h);  
            }
            /*用户-删除*/
            function member_del(obj,id){
                layer.confirm('确认要删除吗？',function(index){
                    //发异步删除数据
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                });
            }


            //首页
            function begin1(){
                $("#a1").attr("value",1);
                var number=$("#a1").val();
                <c:if test="${not empty NameLike}">
                location.href="putinlocation/selNameLike?name="+"${NameLike}"+"&page="+number;
                </c:if>
                <c:if test="${empty NameLike}">
                location.href="putinlocation/SelAllPutIn?page="+number;
                </c:if>
            }
            //上一页
            function upper1(){
                if(parseInt($("#a1").val())<=1){
                    $("#a1").val().attr("value",1);
                }
                $("#a1").attr("value",parseInt($("#a1").val())-1);
                var number=$("#a1").val();
                <c:if test="${not empty NameLike}">
                location.href="putinlocation/selNameLike?name="+"${NameLike}"+"&page="+number;
                </c:if>
                <c:if test="${empty NameLike}">
                location.href="putinlocation/SelAllPutIn?page="+number;
                </c:if>
            }
            //下一页
            function lower1(){
                if(parseInt($("#a1").val())>=${GoodsPageMax}){
                    $("#a1").val().attr("value",${GoodsPageMax})
                }
                $("#a1").attr("value",parseInt($("#a1").val())+1);
                var number=$("#a1").val();
                <c:if test="${not empty NameLike}">
                location.href="putinlocation/selNameLike?name="+"${NameLike}"+"&page="+number;
                </c:if>
                <c:if test="${empty NameLike}">
                location.href="putinlocation/SelAllPutIn?page="+number;
                </c:if>
            }
            //尾页
            function end1(){
                $("#a1").attr("value",${GoodsPageMax});
                var number=$("#a1").val();
                <c:if test="${not empty NameLike}">
                location.href="putinlocation/selNameLike?name="+"${NameLike}"+"&page="+number;
                </c:if>
                <c:if test="${empty NameLike}">
                location.href="putinlocation/SelAllPutIn?page="+number;
                </c:if>
            }

            function upwarecode(id){
                if(window.confirm("确认通过该商品的入库请求吗?")){
                    location.href="putinlocation/upPuInCode?id="+id;
                    alert("该商品已成功入库！请查看货物信息！");
                }
            }

            function uputcode(id){
                if(window.confirm("确认驳回该商品的入库请求吗?")){
                    location.href="putinlocation/upPutCode?id="+id;
                    alert("已成功驳回！");
                }
            }
            </script>
            
    </body>
</html>